home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / dos-msc.im < prev    next >
Encoding:
Text File  |  1994-03-01  |  5.9 KB  |  229 lines

  1. // These two defines are the C compiler and the flags. -c is needed to
  2. // ensure compilation-only; -O is selected to turn debugging off.
  3. #define CC              "cl"
  4. #define CFLAGS          "-c -W3 -O -AS"
  5.  
  6. // The following two macros are the library manager. That program
  7. // is started as "AR ARFLAGS library-name object-files".
  8. #define AR              "lib"
  9.  
  10. // A remove program..
  11. #define RM              "del"
  12.  
  13. // The destination directory to copy executables to, and your install
  14. // program ("cp" for a poor man's solution).
  15. #define BINDIR          "c:\\sys\\ec"
  16. #define CP              "copy"
  17.  
  18. // You've edited enough now. Try making it.
  19.  
  20. #define LIB_ICRSS       "icrss.lib"
  21. #define LIB_ICMAKE      "icmake.lib"
  22. #define LIB_ICMPP       "icmpp.lib"
  23. #define LIB_ICMCOMP     "icmcomp.lib"
  24. #define LIB_ICMEXEC     "icmexec.lib"
  25. #define LIB_ICMUN       "icmun.lib"
  26. #define ZIP             "icmake.zip"
  27.  
  28. void makelib (string dir, string lib, string mainobj)
  29. {
  30.     list
  31.         cfiles,
  32.         ofiles;
  33.     string
  34.         ofile,
  35.         cfile;
  36.     int
  37.         i;
  38.  
  39.     chdir (dir);
  40.  
  41.     mainobj = change_ext (mainobj, ".obj");
  42.  
  43.     printf ("Checking .c files against library ", lib, "\n");
  44.     cfiles = makelist ("*.c");
  45.     for (i = 0; i < sizeof (cfiles); i++)
  46.     {
  47.         cfile = element (i, cfiles);
  48.         ofile = change_ext (cfile, ".obj");
  49.         if (cfile older lib ||
  50.             (exists (ofile) && ofile younger cfile)
  51.            )
  52.         {
  53.             cfiles -= (list) cfile;
  54.             i--;
  55.         }
  56.     }
  57.     if (cfiles)
  58.         execute (CC, CFLAGS, "", cfiles, "", "");
  59.  
  60.     printf ("Checking .obj files against library ", lib, "\n");
  61.     ofiles = makelist ("*.obj") - (list) mainobj;
  62.     if (ofiles)
  63.     {
  64.         execute (AR, lib, "-+", ofiles, "", ";");
  65.         for (i = 0; i < sizeof (ofiles); i++)
  66.             system (RM + " " + element (i, ofiles));
  67.     }
  68.  
  69.     system (RM + " " + change_ext(lib, "bak"));
  70.  
  71.     chdir ("..");
  72. }
  73.  
  74. void makelibs ()
  75. {
  76.     printf ("\nMaking Run Time Support System library\n");
  77.     makelib ("rss", LIB_ICRSS, "");
  78.  
  79.     printf ("\nMaking lib for shell program icmake\n");
  80.     makelib ("make", LIB_ICMAKE, "icmake");
  81.  
  82.     printf ("\nMaking lib for preprocessor icm-pp\n");
  83.     makelib ("pp", LIB_ICMPP, "icm-pp");
  84.  
  85.     printf ("\nMaking lib for compiler icm-comp\n");
  86.     makelib ("comp", LIB_ICMCOMP, "icm-comp");
  87.  
  88.     printf ("\nMaking lib for executor icm-exec\n");
  89.     makelib ("exec", LIB_ICMEXEC, "icm-exec");
  90.  
  91.     printf ("\nMaking lib for unassembler icmun\n");
  92.     makelib ("un", LIB_ICMUN, "icmun");
  93. }
  94.  
  95. void makeprog (string dir, string lib, string prog)
  96. {
  97.     string
  98.         exepacked_prog,
  99.         rsslib;
  100.  
  101.  
  102.     rsslib = "..\\rss\\icrss.lib";
  103.     exepacked_prog = "..\\bindos\\" + prog;
  104.  
  105.     chdir (dir);
  106.  
  107.     printf ("Checking prog ", exepacked_prog, " against libs ", lib,
  108.             " and ", rsslib, "\n");
  109.     if (lib younger exepacked_prog || rsslib younger exepacked_prog)
  110.     {
  111.         exec (CC, change_ext (prog, ".obj"), lib, rsslib);
  112.         exec ("exepack", prog, exepacked_prog);
  113.         system("del " + prog);
  114.     }
  115.  
  116.  
  117.     chdir ("..");
  118. }
  119.  
  120. void makeprogs ()
  121. {
  122.     makelibs ();
  123.  
  124.     printf ("\nMaking shell program icmake\n");
  125.     makeprog ("make", LIB_ICMAKE, "icmake.exe");
  126.  
  127.     printf ("\nMaking preprocessor program icm-pp\n");
  128.     makeprog ("pp", LIB_ICMPP, "icm-pp.exe");
  129.  
  130.     printf ("\nMaking compiler program icm-comp\n");
  131.     makeprog ("comp", LIB_ICMCOMP, "icm-comp.exe");
  132.  
  133.     printf ("\nMaking executor program icm-exec\n");
  134.     makeprog ("exec", LIB_ICMEXEC, "icm-exec.exe");
  135.  
  136.     printf ("\nMaking unassembler program icmun\n");
  137.     makeprog ("un", LIB_ICMUN, "icmun.exe");
  138. }
  139.  
  140. void inst (string prog)
  141. {
  142.     string
  143.         dest;
  144.  
  145.     chdir ("bindos");
  146.     dest = BINDIR + "\\" + prog;
  147.  
  148.     if (prog newer dest)
  149.         system (CP + " " + prog + " " + BINDIR);
  150.  
  151.     chdir ("..");
  152. }
  153.  
  154. void install ()
  155. {
  156.     makeprogs ();
  157.  
  158.     printf ("\nInstalling shell program icmake\n");
  159.     inst ("icmake.exe");
  160.  
  161.     printf ("\nInstalling preprocessor program icm-pp\n");
  162.     inst ("icm-pp.exe");
  163.  
  164.     printf ("\nInstalling compiler program icm-comp\n");
  165.     inst ("icm-comp.exe");
  166.  
  167.     printf ("\nInstalling executor program icm-exec\n");
  168.     inst ("icm-exec.exe");
  169.  
  170.     printf ("\nInstalling unassembler program icmun\n");
  171.     inst ("icmun.exe");
  172. }
  173.  
  174. void clean (string dir, string lib, string prog)
  175. {
  176.     chdir (dir);
  177.  
  178.     lib = change_ext (lib, ".bak");
  179.     if (exists (lib))
  180.         system (RM + " " + lib);
  181.     if (prog && exists (prog))
  182.         system (RM + " " + prog);
  183.  
  184.     chdir ("..");
  185. }
  186.  
  187. void cleanup ()
  188. {
  189.     clean ("rss", LIB_ICRSS, "");
  190.     clean ("make", LIB_ICMAKE, "icmake.exe");
  191.     clean ("pp", LIB_ICMPP, "icm-pp.exe");
  192.     clean ("comp", LIB_ICMCOMP, "icm-comp.exe");
  193.     clean ("exec", LIB_ICMEXEC, "icm-exec.exe");
  194.     clean ("un", LIB_ICMUN, "icmun.exe");
  195. }
  196.  
  197. void main (int argc, list argv)
  198. {
  199.     string
  200.         av1;
  201.  
  202.     echo (1);
  203.  
  204.     av1 = element (1, argv);
  205.     if (av1 == "libs")
  206.         makelibs ();
  207.     else if (av1 == "progs")
  208.         makeprogs ();
  209.     else if (av1 == "install")
  210.         install ();
  211.     else if (av1 == "clean")
  212.         cleanup ();
  213.     else if (av1 == "fresh")
  214.     {
  215.         install ();
  216.         cleanup ();
  217.     }
  218.     else
  219.         printf ("Make what?\n"
  220.                 "Select one of the following:\n"
  221.                 "    \"icmake dos-msc -- libs\" to make libraries\n"
  222.                 "    \"icmake dos-msc -- progs\" to make programs\n"
  223.                 "    \"icmake dos-msc -- install\" to install programs to ",
  224.                                                         BINDIR, "\n"
  225.                 "    \"icmake dos-msc -- clean\" to remove old mush\n"
  226.                 "    \"icmake dos-msc -- fresh\" to install and clean\n"
  227.                 "\n");
  228. }
  229.